﻿#include "msgsocket.h"
#include <QDebug>
#include <QBuffer>
#include <QStringBuilder>

MsgSocket::MsgSocket(QThread *parent) :
    QThread(parent)
{
    m_imageIndex = 0;
    m_imageCount = 0;
    m_imagePathList.clear();
    m_isExit = false;
    m_tcpBlockSize = 0;

    m_tcpSocket = new QTcpSocket(this);
    connect(m_tcpSocket, SIGNAL(readyRead()),
            this, SLOT(slotReadyRead()));
    connect(m_tcpSocket, SIGNAL(disconnected()),
            this, SIGNAL(signalErrorInterNet()));
    connect(this, SIGNAL(signalSendMsg(const QString&)),
            this, SLOT(slotSendMsg(const QString&)));
    connect(this,SIGNAL(signalSendImage(const QString&,const QString&)),
            this,SLOT(slotSendImage(const QString&,const QString&)));

    m_tcpSocket->connectToHost(
                GlobalVars::g_localConfig.readIpAdress(),
                GlobalVars::g_localConfig.readPort().toUShort());
}

MsgSocket::~MsgSocket()
{

}

void MsgSocket::exitThread(void)
{
    m_isExit = true;
}

void MsgSocket::run()
{
    while(!m_isExit)
    {
        if(!GlobalVars::g_msgQueue.isEmpty())
        {
            QString msg = GlobalVars::g_msgQueue.dequeue();
            parseUserAsk(msg);
        }

        if (!GlobalVars::g_ImageMsgQueue.isEmpty())
        {
            ImageMsgMap imageMap = GlobalVars::g_ImageMsgQueue.dequeue();
            parseUserAsk(imageMap);
        }
        msleep(20);
    }
}

///解析通用请求命令
void MsgSocket::parseUserAsk(QString msg)
{
    QStringList list = msg.split("#");
    if (list.size() < 2)
    {
        return;
    }

    int cmd = msg.at(0).toLatin1();
    switch (cmd) {
    ///通用请求命令
    case CMD_UserRegister_R: parseUserRegister(list.at(1)); break;
    case CMD_UserLogin_L: parseUserLogin(list.at(1)); break;
    case CMD_UserExit_X: parseUserExit(list.at(1)); break;
    case CMD_UserInfo_I: parseUserInfo(list.at(1)); break;
    case CMD_ModifyPswd_P: parseModifyPasswordResult(list.at(1)); break;
    case CMD_UpdateUserInfo_U: parseModifyUserInfosResult(list.at(1)); break;
    case CMD_UploadHeadPic_j: parseUploadHeadPicResult(list.at(1)); break;
    case CMD_BusinessCertificate_C: parseUploadCertificateResult(list.at(1)); break;

    case CMD_HotelSearch_S: parseHotelInfoList(list.at(1)); break;
    case CMD_SubmitReserve_D: parseSubmitReserveResult(list.at(1)); break;

    case CMD_HouseList_H: parseGetHouseList(list.at(1)); break;
    case CMD_ReserveList_d: parseGetReserveList(list.at(1)); break;
    case CMD_ReserveDelete_l: parseReserveDelete(list.at(1)); break;
    case CMD_ReserveDetails_a: parseGetReserveDetails(list.at(1)); break;
    case CMD_SubmitComment_p: parseSubmitCommentResult(list.at(1)); break;
    case CMD_CommentList_A: parseGainComment(list.at(1)); break;
    case CMD_SubmitCommentImage_m: parseSubmitCommentImageResult(list.at(1)); break;

    case CMD_SaveList_s: parseGetSaveList(list.at(1)); break;
    case CMD_SubmitSave_c: parseSubmitSaveResult(list.at(1)); break;
    case CMD_HotelDetailsByID_B: parseHotelDetails(list.at(1)); break;

    ///////////////////////////////business////////////////////////////////////////
    case CMD_HotelManageIdAndName_V: parseHotelManageIdAndName(list.at(1)); break;
    case CMD_HotelManageList_Z: parseHotelManageList(list.at(1)); break;
    case CMD_SubmitHouse_w: parseSubmitHouseResult(list.at(1)); break;
    case CMD_SubmitHouseImage_q: parseSubmitHouseImageResult(list.at(1)); break;
    case CMD_DeleteHouse_y: parseDeleteHouseResult(list.at(1)); break;
    case CMD_SubmitHotel_W: parseSubmitHotelResult(list.at(1)); break;
    case CMD_SubmitHotelImage_Q: parseSubmitHotelImageResult(list.at(1)); break;
    case CMD_DeleteHotel_Y: parseDeleteHotelResult(list.at(1)); break;

    case CMD_OrderManageList_x: parseOrderManageList(list.at(1)); break;
    case CMD_ModifyOrderState_u: parseModifyOrderState(list.at(1)); break;
    case CMD_SubmitBusComment_r: parseSubmitBusCommentResult(list.at(1)); break;


        ///////////////////////////////worker////////////////////////////////////////
    case CMD_HotelCertResult_K: parseHotelCertResult(list.at(1)); break;
    case CMD_UserCert_O: parseUserCertList(list.at(1)); break;
    case CMD_UserCertResult_J: parseUserCertResult(list.at(1)); break;
    default: qDebug() << "收到的解析命令不对" << QString(cmd);  break;
    }
}

/// QString  +  QByteArray
/// cmd + id + item + image
void MsgSocket::parseUserAsk(const ImageMsgMap& imageMap)
{
     QStringList strList = imageMap.keys();
     QString index = strList.at(0);
     strList = index.split("#");
     if (strList.size() < 2)
     {
         return;
     }

     int cmd = index.at(0).toLatin1();
     switch (cmd)
     {
         case CMD_HeadPic_i: parseUseImage(strList.at(1), imageMap.value(index)); break;///头像
         case CMD_HotelImageSearch_M: parseHotelImageSearch(strList.at(1), imageMap.value(index)); break;
         case CMD_HotelImageDetail_t: parseHotelDetailsImage(strList.at(1), imageMap.value(index)); break;
         case CMD_HouseImage_T: parseHouseImage(strList.at(1), imageMap.value(index)); break;
         case CMD_HotelImageSave_v: parseSaveHotelImage(strList.at(1), imageMap.value(index)); break;
         case CMD_HotelImageOrder_o: parseReserveHotelImage(strList.at(1), imageMap.value(index)); break;
         case CMD_CommentImage_E: parseCommentImage(strList.at(1), imageMap.value(index)); break;
         case CMD_HotelCredImage_e: parseHotelCredImage(strList.at(1), imageMap.value(index)); break;

         ////////////////////////**********business********//////////////////////////////////
         case CMD_HotelManageImage_z: parseHotelManageImage(strList.at(1), imageMap.value(index)); break;

         ////////////////////////**********business********//////////////////////////////////
         case CMD_UserCertImage_K: parseUserCertImage(strList.at(1), imageMap.value(index)); break;
         default:        break;
     }
}

void MsgSocket::parseUseImage(QString data,const QImage& image)
{
    QStringList list = data.split("|");

    int res = data.at(0).toLatin1();
    if (RES_Down == res)
    {
        emit signalUserImageResult(true,image);
    }else
    {
        emit signalUserImageResult(false,image);
    }
}

void MsgSocket::parseUserLogin(QString data)
{
//    qDebug() << "MsgSocket::parseUserLogin" << data;
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    if (RES_Down == res)
    {
        GlobalVars::g_localUser.setNumber(list.at(1));
        GlobalVars::g_localUser.setRole(list.at(2));

        emit signalUserLoginResult(true,list.at(2));
    }else
    {
        emit signalUserLoginResult(false,list.at(2));
    }
}

void MsgSocket::parseUserExit(QString data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    QString uid = list.at(1);

    if((RES_Down == res)&&(uid == GlobalVars::g_localUser.getNumber()))
    {
        emit signalUserLogoutResult(true);
    }
}

void MsgSocket::parseUserRegister(QString data)
{
    qDebug() << "MsgSocket::parseUserRegister" << data;
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    if (RES_Down == res)
    {
        GlobalVars::g_localUser.setNumber(list.at(1));
        GlobalVars::g_localUser.setRole(list.at(2));

        emit signalUserRegisterResult(true,list.at(2));
    }else
    {
        emit signalUserRegisterResult(false,list.at(2));
    }
}

void MsgSocket::parseModifyPasswordResult(QString data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    if (RES_Down == res)
    {
        emit signalModifyPasswordResult(true,list.at(2));
    }else
    {
        emit signalModifyPasswordResult(false,list.at(2));
    }
}

void MsgSocket::parseModifyUserInfosResult(QString data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    if (RES_Down == res)
    {
        emit signalModifyUserInfosResult(true,list.at(2));
    }else
    {
        emit signalModifyUserInfosResult(false,list.at(2));
    }
}

void MsgSocket::parseUploadHeadPicResult(QString data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();

    if (RES_Down == res)
    {
        QString msg = QString(CMD_HeadPic_i)
            % QString("#") % GlobalVars::g_localUser.getNumber();
        emit signalSendMsg(msg);
    }
}

void MsgSocket::parseUploadCertificateResult(QString data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();

    if (RES_Down == res)
    {
        if (m_imageIndex >= m_imageCount) ///全部发送
        {
            emit signalUploadCertificateResult(true,"");
            return;
        }

        QString msg = QString(CMD_BusinessCertificate_C)
            % QString("#") % GlobalVars::g_localUser.getNumber();
        sendMoreImage(msg);
        emit signalUploadCertImageSchedule();
    }else
    {
        emit signalUploadCertificateResult(false,list.at(1));
    }
}

void MsgSocket::parseUserInfo(QString data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    if (RES_Down == res)
    {
        GlobalVars::g_localUser.setNumber(list.at(1));
        GlobalVars::g_localUser.setName(list.at(2));
        GlobalVars::g_localUser.setSex(list.at(3));
        GlobalVars::g_localUser.setBirthday(list.at(4));
        GlobalVars::g_localUser.setPhone(list.at(5));
        GlobalVars::g_localUser.setEmail(list.at(6));
        GlobalVars::g_localUser.setRealName(list.at(7));
        GlobalVars::g_localUser.setCertificate(list.at(8));

        emit signalGainUserInfoResult(true,list.at(2));
    }else
    {
        emit signalGainUserInfoResult(false,list.at(2));
    }
}

void MsgSocket::slotReadyRead()
{
    QDataStream in(m_tcpSocket);
    in.setVersion(QDataStream::Qt_4_6);

    if(m_tcpBlockSize == 0)
    {
        if(m_tcpSocket->bytesAvailable()<sizeof(quint16))
            return;

        in >> m_tcpBlockSize;
    }

    if(m_tcpSocket->bytesAvailable() < m_tcpBlockSize)
        return;

    int type;
     in >> type;
     if (type == Msg_Image)
     {
         ImageMsgMap imageMap;
         QByteArray buffer;
         QImage image;
         QString msg;
         in >> msg;
         in >> buffer;

         qDebug() << "Client Recv: " << msg + "    --- image!!!";
         image.loadFromData(buffer);
         imageMap.insert(msg,image);
         GlobalVars::g_ImageMsgQueue.enqueue(imageMap);
     }else if(type == Msg_Word)
     {
         QString msg;
         in >> msg;
         qDebug() << "Client Recv: " << msg;
         GlobalVars::g_msgQueue.enqueue(msg);
     }
     else{
         QString msg;
         in >> msg;
         qDebug() << "Client Recv error: " << msg;
     }

    m_tcpBlockSize = 0;
}

void MsgSocket::slotSendMsg(const QString &msg)
{
    QByteArray buffer;
    QDataStream out(&buffer, QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_4_6);

    out << (quint16)0;
    out << Msg_Word;
    out << msg;
    out.device()->seek(0);
    out << (quint16)(buffer.size() - sizeof(quint16));

    qDebug() << "Client Send Msg: " << msg;
    m_tcpSocket->write(buffer);
}

void MsgSocket::slotSendImage(const QString& msg,const QString& path)
{
    QByteArray buffer;
    QDataStream out(&buffer, QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_5_4);

    QBuffer buf;
    QImage image(path);
    qDebug() << "image.size " << image.width() << image.height();
    buf.open(QIODevice::ReadWrite);
    image.save(&buf,"PNG");

    out << (quint16)0;
    out << Msg_Image;
    out << msg;
    out << buf.data();
    out.device()->seek(0);
    out << (quint16)(buffer.size() - sizeof(quint16));

    qDebug() << "Client Send Image: " << msg;
    m_tcpSocket->write(buffer);
}

void MsgSocket::slotSendImage(const QString& msg, const QStringList& pathList)
{
    qDebug() << pathList;
    m_imageIndex = 0;
    m_imageCount = 0;
    m_imagePathList = pathList;
    if (m_imagePathList.size() != 0)
    {
        m_imageCount = m_imagePathList.size();
        sendMoreImage(msg);
    }
}

void MsgSocket::sendMoreImage(const QString& msg)
{
    if (m_imageIndex >= m_imageCount)
    {
        return;
    }else
    {
        QString message = msg % "|" % QString::number(m_imageCount)
                                             % "|" % QString::number(m_imageIndex);
        emit signalSendImage(message,m_imagePathList[m_imageIndex]);
        m_imageIndex++;
    }
}

void MsgSocket::parseHotelInfoList(QString data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    /// !/?  hotel name star location mark commentCount price
    /// OpenedTime DecoratedTime Phone Cancellation Instruction server
    /// size
    if (RES_Down == res)
    {
        GlobalVars::g_localHotel.setHotel(list.at(1));
        GlobalVars::g_localHotel.setName(list.at(2));
        GlobalVars::g_localHotel.setStar(list.at(3));
        GlobalVars::g_localHotel.setLocation(list.at(4));
        GlobalVars::g_localHotel.setMark(list.at(5));
        GlobalVars::g_localHotel.setCommentCount(list.at(6).toInt());
        GlobalVars::g_localHotel.setLowPrice(list.at(7).toInt());
        GlobalVars::g_localHotel.setServer(list.at(8));
        if (GlobalVars::count == 0)
        {
            GlobalVars::count = list.at(9).toInt();
        }

        emit signalSetHotelInfoList(true,"");                             /// 设置显示酒店的信息

        QString msg = QString(CMD_HotelSearchNext_N)         ///获取下一个酒店信息
            % QString("#") % GlobalVars::g_localUser.getNumber();
        emit signalSendMsg(msg);
    }else
    {
        if (list.at(1) == "没有下一条记录")                                  /// 请求照片 + (请求下一页记录)/(没有下一条记录)
        {
            QString msg = QString(CMD_HotelImageSearch_M)            ///获取酒店image
                    % QString("#") % GlobalVars::g_localUser.getNumber();
           emit signalSendMsg(msg);
        }

        emit signalSetHotelInfoList(false,list.at(1));
    }
}
void MsgSocket::parseHotelImageSearch(QString data, const QImage &image)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();

    if (RES_Down == res)
    {
        QString hotelID = list.at(1);
        QString msg = QString(CMD_HotelImageSearch_M)                 ///获取下一个酒店image
            % QString("#") % GlobalVars::g_localUser.getNumber();
        emit signalSendMsg(msg);
        emit signalHotelSearchImage(hotelID,image);                            ///设置酒店image
    }else                                                                                 ///没有酒店image 或者 没有下一个image
    {
        qDebug() << "parseHotelImageSearch" << list.at(1);
    }
}

void MsgSocket::parseSubmitReserveResult(QString data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    ///!/? | msgRemind
    if (RES_Down == res)
    {
        emit signalSubmitReserveResult(true,list.at(1));
    }else
    {
        emit signalSubmitReserveResult(false,list.at(1));
    }
}

void MsgSocket::parseGetReserveList(QString data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
     /// !/? reserveID hotelName houseCount houseType checkInTime checkOutTime payment state hotelID commentState
     ///  !/? msgRemind
    if (RES_Down == res)
    {
        GlobalVars::g_localReserve.setReserve(list.at(1));
        GlobalVars::g_localReserve.setHotelName(list.at(2));
        GlobalVars::g_localReserve.setHouseCount(list.at(3).toInt());
        GlobalVars::g_localReserve.setHouseType(list.at(4));
        GlobalVars::g_localReserve.setCheckInTime(list.at(5));
        GlobalVars::g_localReserve.setCheckOutTime(list.at(6));
        GlobalVars::g_localReserve.setPayment(list.at(7).toInt());
        GlobalVars::g_localReserve.setState(list.at(8));
        GlobalVars::g_localReserve.setHotel(list.at(9));
        GlobalVars::g_localReserve.setCommentState(list.at(10));

        emit signalSetReserveList(true,list.at(8),list.at(10));//state comment

        QString msg = QString(CMD_ReserveList_d)                            ///获取下一个订单
            % QString("#") % GlobalVars::g_localUser.getNumber() % "|1";
        emit signalSendMsg(msg);
    }else
    {
        if(list.at(1) == "没有下一条记录")
        {
            QString msg = QString(CMD_HotelImageOrder_o)                 ///获取订单酒店图片
                % QString("#") % GlobalVars::g_localUser.getNumber() % "|0";
            emit signalSendMsg(msg);
        }
        emit signalSetReserveList(false,list.at(1),"");
    }
}

void MsgSocket::parseReserveDelete(QString data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    if (RES_Down == res)
    {
        emit signalReserveDeleteResult(true,list.at(1));//state comment
        slotGainOrederFormList();
    }else
    {
        emit signalReserveDeleteResult(false,list.at(1));
    }
}

void MsgSocket::parseGetReserveDetails(QString data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    /// !/? reserveID hotelID houseType InName InTel InTime OutTime ReserveTime
    /// Payment ReserveHouseCount ReserveState CommentState HotelName HotelPhone HotelLocation
     ///  !/? msgRemind
    if (RES_Down == res)
    {
        GlobalVars::g_localReserve.setReserve(list.at(1));
        GlobalVars::g_localReserve.setHotel(list.at(2));
        GlobalVars::g_localReserve.setHouseType(list.at(3));
        GlobalVars::g_localReserve.setCheckInName(list.at(4));
        GlobalVars::g_localReserve.setCheckInTel(list.at(5));
        GlobalVars::g_localReserve.setCheckInTime(list.at(6));
        GlobalVars::g_localReserve.setCheckOutTime(list.at(7));
        GlobalVars::g_localReserve.setReserveTime(list.at(8));
        GlobalVars::g_localReserve.setPayment(list.at(9).toInt());
        GlobalVars::g_localReserve.setHouseCount(list.at(10).toInt());
        GlobalVars::g_localReserve.setState(list.at(11));
        GlobalVars::g_localReserve.setCommentState(list.at(12));
        GlobalVars::g_localReserve.setHotelName(list.at(13));
        GlobalVars::g_localReserve.setHotelPhone(list.at(14));
        GlobalVars::g_localReserve.setHotelLocation(list.at(15));

        emit signalSetReserveDetails(true,"");//state comment
    }else
    {
        emit signalSetReserveDetails(false,list.at(1));
    }
}

void MsgSocket::parseReserveHotelImage(QString data, const QImage &image)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();

    if (RES_Down == res)
    {
        QString msg = QString(CMD_HotelImageOrder_o)                               /// 获取收藏的下一个酒店的图片
            % QString("#") % GlobalVars::g_localUser.getNumber() % "|1";
        emit signalSendMsg(msg);
        emit signalSetReserveHotelImage(true,list.at(1),image);
    }else
    {
        emit signalSetReserveHotelImage(false,list.at(1),image);
    }
}
////////////////////////////// comment //////////////////////////////////////
void MsgSocket::parseGainComment(QString data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    /// !/? commentID hotelType inTime time comment star hotelComment userName
    if (RES_Down == res)
    {
        GlobalVars::g_localComment.setComment(list.at(1));
        GlobalVars::g_localComment.setHouseType(list.at(2));
        GlobalVars::g_localComment.setCheckInTime(list.at(3));
        GlobalVars::g_localComment.setCommentTime(list.at(4));
        GlobalVars::g_localComment.setUserComment(list.at(5));
        GlobalVars::g_localComment.setStar(list.at(6));
        QString hotelComment = list.at(7);
        GlobalVars::g_localComment.setHotelComment(hotelComment);
        GlobalVars::g_localComment.setUserName(list.at(8));

        GlobalVars::g_commentInfoList->append(GlobalVars::g_localComment);
        slotGainHotelCommentList("1");
        if (GlobalVars::g_localUser.getRole().toInt() == USER_User)
        {
            emit signalSetCommentList(true,"");
        }
        else
        {
            emit signalSetCommentListForBus(true,hotelComment);
        }
    }else
    {
        if (list.at(1) == "没有下一条记录")
        {
            QString msg = QString(CMD_CommentImage_E)                ///获取酒店评论图片
                    % QString("#") % GlobalVars::g_localUser.getNumber()
                    % "|"% GlobalVars::g_localHotel.getHotel() % "|0";
            emit signalSendMsg(msg);
        }
        else
        {
            if (GlobalVars::g_localUser.getRole().toInt() == USER_User)
            {
                emit signalSetCommentList(false,list.at(1));
            }
            else
            {
                emit signalSetCommentListForBus(false,list.at(1));
            }
        }
    }
}
void MsgSocket::parseCommentImage(QString data, const QImage &image)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();

    if (RES_Down == res)
    {
        QString msg = QString(CMD_CommentImage_E)                ///获取酒店评论下一个图片
                    % QString("#") % GlobalVars::g_localUser.getNumber()
                    % "|"% GlobalVars::g_localHotel.getHotel() % "|1";
        emit signalSendMsg(msg);
        if (GlobalVars::g_localUser.getRole().toInt() == USER_User)
        {
            emit signalSetCommentImage(true,list.at(1),image);
        }
        else
        {
            QString commentID = list.at(1);
            if (GlobalVars::g_commentImageListMap.contains(commentID))
            {
                ImageList *imageList = GlobalVars::g_commentImageListMap[commentID];
                imageList->append(image);
            }
            else
            {
                ImageList *imageList = new ImageList();
                imageList->append(image);
                GlobalVars::g_commentImageListMap.insert(commentID,imageList);
            }

            emit signalSetCommentImageForBus(true,list.at(1),image);
        }
    }else
    {
        if (list.at(1) == "没有下一条记录")
        {
            QString msg = QString(CMD_CommentImage_E)                ///获取酒店下一个评论图片
                        % QString("#") % GlobalVars::g_localUser.getNumber()
                        % "|"% GlobalVars::g_localHotel.getHotel() % "|2";
            emit signalSendMsg(msg);
        }
        else                                                                                /// 没有更多评论
        {
            if (GlobalVars::g_localUser.getRole().toInt() == USER_User)
            {
                emit signalSetCommentImage(false,list.at(1),image);
            }
            else
            {
                emit signalSetCommentImageForBus(false,list.at(1),image);
            }
        }
    }
}
void MsgSocket::parseSubmitCommentResult(QString data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    ///!/? | msgRemind
    if (RES_Down == res)
    {
        QString msg = QString(CMD_SubmitCommentImage_m)
                % QString("#") % GlobalVars::g_localUser.getNumber()
                % "|" % GlobalVars::g_localComment.getReserveID()
                % "|" % GlobalVars::g_localComment.getComment();

        slotSendImage(msg,GlobalVars::g_localComment.getPhoto().split("#"));
    }else
    {
        emit signalSubmitCommentResult(false,list.at(1));
    }
}
void MsgSocket::parseSubmitCommentImageResult(QString data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    ///!/? | msgRemind
    if (RES_Down == res)
    {
        if (m_imageIndex >= m_imageCount) ///全部发送
        {
            emit signalSubmitCommentResult(true,list.at(1));
            return;
        }

        QString msg = QString(CMD_SubmitCommentImage_m)
                % QString("#") % GlobalVars::g_localUser.getNumber()
                % "|" % GlobalVars::g_localComment.getReserveID()
                % "|" % GlobalVars::g_localComment.getComment();///reverse
        sendMoreImage(msg);
    }else
    {
        emit signalSubmitCommentResult(false,list.at(1));
    }
}

//////////////////////////////////////////////// save //////////////////////////////////////////////////////////////
void MsgSocket::parseGetSaveList(QString data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
     /// !/? saveID hotelID hotelName Star hotelType location
     ///  !/? msgRemind
    if (RES_Down == res)
    {
        GlobalVars::g_localSave.setSave(list.at(1));
        GlobalVars::g_localSave.setHotel(list.at(2));
        GlobalVars::g_localSave.setHotelName(list.at(3));
        GlobalVars::g_localSave.setStar(list.at(4));
        GlobalVars::g_localSave.setHotelType(list.at(5));
        GlobalVars::g_localSave.setLocation(list.at(6));

        emit signalSetSaveList(true,"");

        QString msg = QString(CMD_SaveList_s)                                               ///获取下一个收藏
            % QString("#") % GlobalVars::g_localUser.getNumber() % "|1";
        emit signalSendMsg(msg);
    }else
    {
        if (list.at(1) == "没有下一条记录")
        {
            QString msg = QString(CMD_HotelImageSave_v)                               /// 获取收藏的酒店的图片
                % QString("#") % GlobalVars::g_localUser.getNumber() % "|0";
            emit signalSendMsg(msg);
        }
        else
        {
            emit signalSetSaveList(false,list.at(1));
        }
    }
}

void MsgSocket::parseSubmitSaveResult(QString data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
     /// !/? saveID hotelID hotelName Star hotelType location
     ///  !/? msgRemind
    if (RES_Down == res)
    {
        emit signalSubmitSaveResult(true,"");
    }else
    {
        emit signalSubmitSaveResult(false,list.at(1));
    }
}

void MsgSocket::parseSaveHotelImage(QString data, const QImage &image)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();

    if (RES_Down == res)
    {
        QString msg = QString(CMD_HotelImageSave_v)                               /// 获取收藏的下一个酒店的图片
            % QString("#") % GlobalVars::g_localUser.getNumber() % "|1";
        emit signalSendMsg(msg);
        emit signalSetSaveHotelImage(true,list.at(1),image);
    }else
    {
        emit signalSetSaveHotelImage(false,list.at(1),image);
    }
}

void MsgSocket::setHotelDetails(const QStringList &list)
{
    /// !/?  hotel name star city mark type Phone location OpenedTimeDecoratedTime lowPrice
    /// highPrice count commentCount Cancellation Instruction description server save
    GlobalVars::g_localHotel.setHotel(list.at(1));
    GlobalVars::g_localHotel.setName(list.at(2));
    GlobalVars::g_localHotel.setStar(list.at(3));
    GlobalVars::g_localHotel.setCity(list.at(4));
    GlobalVars::g_localHotel.setMark(list.at(5));
    GlobalVars::g_localHotel.setType(list.at(6));
    GlobalVars::g_localHotel.setPhone(list.at(7));
    GlobalVars::g_localHotel.setLocation(list.at(8));
    GlobalVars::g_localHotel.setOpenedTime(list.at(9));
    GlobalVars::g_localHotel.setDecoratedTime(list.at(10));
    GlobalVars::g_localHotel.setLowPrice(list.at(11).toInt());
    GlobalVars::g_localHotel.setHighPrice(list.at(12).toInt());
    GlobalVars::g_localHotel.setTotalHouse(list.at(13).toInt());
    GlobalVars::g_localHotel.setCommentCount(list.at(14).toInt());
    GlobalVars::g_localHotel.setCancellation(list.at(15));
    GlobalVars::g_localHotel.setInstruction(list.at(16));
    GlobalVars::g_localHotel.setDescription(list.at(17));
    GlobalVars::g_localHotel.setServer(list.at(18));
    if (list.at(19) == "1")
    {
        GlobalVars::g_localHotel.setIsSave(true);
    }else
    {
        GlobalVars::g_localHotel.setIsSave(false);
    }
}

void MsgSocket::parseHotelCredImage(QString data, const QImage &image)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();

    if (RES_Down == res)
    {
        GlobalVars::g_hotelImageList.append(image);
        slotGainHotelImage("1");                                /// 获取酒店图片
    }else
    {
        GlobalVars::g_hotelImageList.append(image);             ///no-pic
    }
}

////////////////////////////////////////////////HotelDetails///////////////////////////////////////////////////////
///解析酒店详情 + 获取房间列表
void MsgSocket::parseHotelDetails(const QString& data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    if (RES_Down == res)
    {
        setHotelDetails(list);
        emit signalSetHotelDetails(true,"");

        if (GlobalVars::g_localUser.getRole().toInt() == USER_User)
        {
            slotGainHouseList("0");
        }
        else
        {
            slotGainHotelImage("0");
        }
    }else
    {
        emit signalSetHotelDetails(false,list.at(1));
    }
}

///获取房间列表
void MsgSocket::slotGainHouseList(QString index, QString hotelID)
{
    QString msg = QString(CMD_HouseList_H)                                   ///获取房间列表
        % QString("#") % GlobalVars::g_localUser.getNumber()
        % "|" % hotelID % "|" % index ;///hotelID
    emit signalSendMsg(msg);
}

///解析房间信息 + 获取下一个房间信息 + 获取酒店图片
void MsgSocket::parseGetHouseList(QString data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    ///!/? houseID type area bedType window price capacity bathroom Acc
    if (RES_Down == res)
    {
        GlobalVars::g_localHouse.setHouse(list.at(1));
        GlobalVars::g_localHouse.setType(list.at(2));
        GlobalVars::g_localHouse.setArea(list.at(3));
        GlobalVars::g_localHouse.setBedType(list.at(4));
        GlobalVars::g_localHouse.setWindow(list.at(5));
        GlobalVars::g_localHouse.setPrice(list.at(6).toInt());
        GlobalVars::g_localHouse.setCapacity(list.at(7).toInt());
        GlobalVars::g_localHouse.setBathroom(list.at(8));
        GlobalVars::g_localHouse.setBathroomAcc(list.at(9));
        GlobalVars::g_localHouse.setNet(list.at(10));
        GlobalVars::g_localHouse.setBreakfast(list.at(11));
        GlobalVars::g_localHouse.setMedia(list.at(12));
        GlobalVars::g_localHouse.setCount(list.at(13).toInt());

        slotGainHouseList("1");                                     ///获取下一个酒店房间信息
        if (GlobalVars::g_localUser.getRole().toInt() == USER_User)
        {
            emit signalSetHouseList(true,"");                                      ///设置酒店房间信息
        }
        else
        {
            emit signalSetHouseListForBus(true,"");                          ///设置酒店房间信息
        }
    }else
    {
        if (list.at(1) == "没有记录")                                                /// 没有酒店房间的提示图片
        {
            if (GlobalVars::g_localUser.getRole().toInt() == USER_User)
            {
                emit signalSetHouseList(false,list.at(1));                                      ///设置酒店房间信息
            }
            else
            {
                emit signalSetHouseListForBus(false,list.at(1));                          ///设置酒店房间信息
            }
        }else{                                                                                ///没有下一条记录
            if (GlobalVars::g_localUser.getRole().toInt() == USER_User)
            {
                slotGainHotelImage("0");///获取酒店图片
                emit signalSetHouseList(false,list.at(1));                                      ///设置酒店房间信息
            }
            else
            {
                slotGainHouseImage();///获取房间图片
                emit signalSetHouseListForBus(false,list.at(1));                          ///设置酒店房间信息
            }
        }
    }
}

///获取酒店图片
void MsgSocket::slotGainHotelImage(QString index,QString hotelID)
{
    if (index == "0")
    {
        GlobalVars::g_hotelImageList.clear();
    }
    QString msg = QString(CMD_HotelImageDetail_t)
        % QString("#") % GlobalVars::g_localUser.getNumber()
            % "|" % hotelID % "|" % index ;///hotelID
    emit signalSendMsg(msg);
}

///酒店图片 + 获取房间图片
void MsgSocket::parseHotelDetailsImage(QString data, const QImage &image)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    if (RES_Down == res)
    {
        GlobalVars::g_hotelImageList.append(image);
        slotGainHotelImage("1");           ///获取下一个酒店image
    }else                                                                                 ///没有酒店image 或者 没有下一个image
    {
        if (list.at(1) == "没有记录")
        {
            GlobalVars::g_hotelImageList.clear();
        }
        else
        {
            if (GlobalVars::g_localUser.getRole().toInt() == USER_User)
            {
                emit signalHotelDetailsImage();  ///设置酒店image
                GlobalVars::g_houseImageList.clear();
                slotGainHouseImage();          ///获取酒店房间图片信息
            }
            else if (GlobalVars::g_localUser.getRole().toInt() == USER_Business)
            {
                emit signalHotelImageForBus();  ///设置酒店image
                return;
            }
            else
            {
                emit signalHotelImageForWorker();  ///设置酒店image
                return;
            }
        }
    }
}

///获取酒店房间图片信息
void MsgSocket::slotGainHouseImage()
{
    QString msg = QString(CMD_HouseImage_T)
        % QString("#") % GlobalVars::g_localUser.getNumber();
    emit signalSendMsg(msg);
}

///获取酒店评论信息
void MsgSocket::slotGainHotelCommentList(QString index, QString hotelID)
{
    if (index == "0")
    {
        GlobalVars::g_commentImageListMap.clear();
    }
    QString msg = QString(CMD_CommentList_A)                ///获取酒店评论
        % QString("#") % GlobalVars::g_localUser.getNumber()
        % "|" % hotelID % "|" % index;
    emit signalSendMsg(msg);
}

///解析房间图片
void MsgSocket::parseHouseImage(QString data, const QImage &image)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    if (RES_Down == res)
    {
        GlobalVars::g_houseImageList.append(image);
        slotGainHouseImage();          ///获取下一个酒店房间图片信息
        if (GlobalVars::g_localUser.getRole().toInt() == USER_User)
        {
            emit signalHouseImageResult(list.at(1),image);    ///bool  houseType  image
        }
        else
        {
            emit signalHouseImageResultForBus(list.at(1),image);    ///  houseType  image
        }
    }else
    {
        if (list.at(1) == "没有下一条记录")
        {
            if (GlobalVars::g_localUser.getRole().toInt() == USER_User)
            {
                emit signalSetHouseImage();
                slotGainHotelCommentList("0");
            }
        }
    }
}

void MsgSocket::slotGainOrederFormList()
{
    ///获取订单列表
    QString msg = QString(CMD_ReserveList_d)
        % QString("#") % GlobalVars::g_localUser.getNumber() % "|0";
    emit signalSendMsg(msg);
}



////////////////////////////*********** business ************////////////////////////////
void MsgSocket::parseHotelManageIdAndName(const QString& data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
     /// !/? count hotelID hotelName mark commentCount state
     ///  !/? msgRemind
     int size = list.at(1).toInt();
     qDebug() << list.size();
    if (RES_Down == res)
    {
        if (size != 0)
        {
            for (int i = 0; i < size; i++)
            {
                if (list.at(5*i+6) == "已审核")
                {
                    QString hotelID = list.at(5*i+2);
                    QString hotelName = list.at(5*i+3);
                    QString mark = list.at(5*i+4);
                    int commentCount = list.at(5*i+5).toInt();

                    HotelInfo hotel;
                    hotel.setHotel(hotelID);
                    hotel.setName(hotelName);
                    hotel.setMark(mark);
                    hotel.setCommentCount(commentCount);

                    GlobalVars::g_hotelManageList->append(hotel);
                }
            }
            for(HotelInfoList::iterator it = GlobalVars::g_hotelManageList->begin();
                it != GlobalVars::g_hotelManageList->end(); it++)
            {
               GlobalVars::g_hotelManageMap.insert(it->getHotel(), it);
            }
        }
    }else
    {
        if (size == 0)
        {
            GlobalVars::g_hotelManageMap.clear();
            GlobalVars::g_hotelManageList->clear();
        }
    }
}
void MsgSocket::parseHotelManageList(const QString& data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
     /// !/? hotelID hotelName Star hotelType location state
     ///  !/? msgRemind
    if (RES_Down == res)
    {
        GlobalVars::g_localHotel.setHotel(list.at(1));
        GlobalVars::g_localHotel.setName(list.at(2));
        GlobalVars::g_localHotel.setMark(list.at(3));
        GlobalVars::g_localHotel.setType(list.at(4));
        GlobalVars::g_localHotel.setLocation(list.at(5));
        GlobalVars::g_localHotel.setState(list.at(6));

        if (GlobalVars::g_localUser.getRole().toInt() == USER_Business)
        {
            emit signalSetHotelManageList(true,list.at(6));

            if (list.at(6) == "已审核")
            {
                GlobalVars::g_hotelManageList->append(GlobalVars::g_localHotel);
            }
        }
        else
        {
            GlobalVars::g_localHotel.setStar(list.at(7));
            GlobalVars::g_localHotel.setUser(list.at(8));    /// 用户名
            GlobalVars::g_localHotel.setPhone(list.at(9));  /// 用户电话
            GlobalVars::g_localHotel.setLowPrice(list.at(10).toInt());
            GlobalVars::g_localHotel.setTotalHouse(list.at(11).toInt());

            GlobalVars::g_hotelManageList->append(GlobalVars::g_localHotel);
        }

        QString msg = QString(CMD_HotelManageList_Z)                    ///获取下一个可管理的酒店
            % QString("#") % GlobalVars::g_localUser.getNumber() % "|1";
        emit signalSendMsg(msg);
    }else
    {
        if (list.at(1) == "没有下一条记录")
        {
            QString msg = QString(CMD_HotelManageImage_z)                  /// 获取可管理的酒店的图片
                % QString("#") % GlobalVars::g_localUser.getNumber() % "|0";
            emit signalSendMsg(msg);

            if (GlobalVars::g_localUser.getRole().toInt() == USER_Worker)
            {
                emit signalSetHotelCertList();
            }

            for(HotelInfoList::iterator it = GlobalVars::g_hotelManageList->begin();
                it != GlobalVars::g_hotelManageList->end(); it++)
            {
               GlobalVars::g_hotelManageMap.insert(it->getHotel(), it);
            }
        }
        else /// 没有可管理的酒店
        {
            if (GlobalVars::g_localUser.getRole().toInt() == USER_Business)
            {
                emit signalSetHotelManageList(false,list.at(1));
            }
            else
            {
                emit signalSetHotelCertList();
            }
        }
    }
}
void MsgSocket::parseHotelManageImage(QString data, const QImage &image)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();

    if (RES_Down == res)
    {
        QString msg = QString(CMD_HotelManageImage_z)                  /// 获取下一个可管理的酒店的图片
            % QString("#") % GlobalVars::g_localUser.getNumber() % "|1";
        emit signalSendMsg(msg);
        emit signalSetHotelManageImage(true,list.at(1),image);
    }else
    {
        emit signalSetHotelManageImage(false,list.at(1),image);
    }
}
void MsgSocket::parseSubmitHouseResult(const QString& data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    ///!/? | msgRemind
    if (RES_Down == res)
    {
        /// 上传照片
        QString msg = QString(CMD_SubmitHouseImage_q)
                % QString("#") % GlobalVars::g_localUser.getNumber()
                % "|" % GlobalVars::g_localHouse.getHouse();

        slotSendImage(msg,GlobalVars::g_localHouse.getPhoto().split("#"));
    }else
    {
        emit signalSubmitHouseResult(false,list.at(1));
    }
}
void MsgSocket::parseSubmitHouseImageResult(const QString& data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    ///!/? | msgRemind
    if (RES_Down == res)
    {
        if (m_imageIndex >= m_imageCount) ///全部发送
        {
            emit signalSubmitHouseResult(true,list.at(1));
            return;
        }

        QString msg = QString(CMD_SubmitHouseImage_q)
                % QString("#") % GlobalVars::g_localUser.getNumber()
                % "|" % GlobalVars::g_localHouse.getHouse();
        sendMoreImage(msg);
    }else
    {
        emit signalSubmitHouseResult(false,list.at(1));
    }
}
void MsgSocket::parseDeleteHouseResult(const QString& data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    ///!/? | msgRemind
    if (RES_Down == res)
    {
        emit signalDeleteHouseResult(true,list.at(1));
    }else
    {
        emit signalDeleteHouseResult(false,list.at(1));
    }
}
void MsgSocket::parseSubmitHotelResult(const QString& data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    ///!/? | msgRemind
    if (RES_Down == res)
    {
        /// 上传照片
        QString msg = QString(CMD_SubmitHotelImage_Q)
                % QString("#") % GlobalVars::g_localUser.getNumber()
                % "|" % GlobalVars::g_localHotel.getHotel();

        QStringList pathList;
        pathList.append(GlobalVars::g_localHotel.getBusinessLicense());
        pathList += GlobalVars::g_localHotel.getPhoto().split("#");
        slotSendImage(msg,pathList);
    }else
    {
        emit signalSubmitHotelResult(false,list.at(1));
    }
}
void MsgSocket::parseSubmitHotelImageResult(const QString& data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    ///!/? | msgRemind
    if (RES_Down == res)
    {
        if (m_imageIndex >= m_imageCount) ///全部发送
        {
            emit signalSubmitHotelResult(true,list.at(1));
            return;
        }

        QString msg = QString(CMD_SubmitHotelImage_Q)
                % QString("#") % GlobalVars::g_localUser.getNumber()
                % "|" % GlobalVars::g_localHotel.getHotel();
        sendMoreImage(msg);
    }else
    {
        emit signalSubmitHotelResult(false,list.at(1));
    }
}
void MsgSocket::parseDeleteHotelResult(const QString& data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    ///!/? | msgRemind
    if (RES_Down == res)
    {
        emit signalDeleteHotelResult(true,list.at(1));
    }else
    {
        emit signalDeleteHotelResult(false,list.at(1));
    }
}

void MsgSocket::parseOrderManageList(const QString& data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    /// !/?  reserveID hotelID ReserveTime HouseCount hotelType Pay CheckInName
    ///  CheckInTel HouseType State
    if (RES_Down == res)
    {
        QString hotelID = list.at(2);
        GlobalVars::g_localReserve.setReserve(list.at(1));
        GlobalVars::g_localReserve.setHotel(hotelID);
        GlobalVars::g_localReserve.setReserveTime(list.at(3));
        GlobalVars::g_localReserve.setHouseType(list.at(4));
        GlobalVars::g_localReserve.setHouseCount(list.at(5).toInt());
        GlobalVars::g_localReserve.setPayment(list.at(6).toInt());
        GlobalVars::g_localReserve.setCheckInName(list.at(7));
        GlobalVars::g_localReserve.setCheckInTel(list.at(8));
        GlobalVars::g_localReserve.setCheckInTime(list.at(9));
        GlobalVars::g_localReserve.setCheckOutTime(list.at(10));
        GlobalVars::g_localReserve.setArrivalTime(list.at(11));
        GlobalVars::g_localReserve.setState(list.at(12));

        GlobalVars::g_reserveInfoList->append(GlobalVars::g_localReserve);
        QString msg = QString(CMD_OrderManageList_x)
            % QString("#") % GlobalVars::g_localUser.getNumber()
            % "|" % hotelID % "|1";
        emit signalSendMsg(msg);
    }
    else
    {
        if (GlobalVars::g_localUser.getRole().toInt() == USER_Business)
        {
            emit signalUpdateOrderManageShow();             /// 数据获取成功，model刷新界面
        }
        else
        {
            emit signalUpdateOrderShowForWorker();             /// 数据获取成功，model刷新界面
        }
    }
}
void MsgSocket::parseModifyOrderState(const QString& data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    /// !/?  message
    if (RES_Down == res)
    {
        emit signalModifyOrderStateResult(true,list.at(1));
    }
    else
    {
        emit signalModifyOrderStateResult(false,list.at(1));
    }
}
void MsgSocket::parseSubmitBusCommentResult(const QString& data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    ///!/? | msgRemind
    if (RES_Down == res)
    {
        emit signalSubmitBusCommentResult(true,"");
    }else
    {
        emit signalSubmitBusCommentResult(false,list.at(1));
    }
}



//////////////////////////////////////////////// worker //////////////////////////////////////////////////////////////
void MsgSocket::parseHotelCertResult(const QString& data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();
    ///!/? | msgRemind
    if (RES_Down == res)
    {
        emit signalHotelCertResult(true,list.at(1));
    }else
    {
        emit signalHotelCertResult(false,list.at(1));
    }
}

void MsgSocket::parseUserCertList(const QString& data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();

    ///!/? | msgRemind
    if (RES_Down == res)
    {
        UserInfo userInfo;
        userInfo.setNumber(list.at(1));
        userInfo.setName(list.at(2));
        userInfo.setSex(list.at(3));
        userInfo.setRealName(list.at(4));

        GlobalVars::g_userInfoList->append(userInfo);
        QString msg = QString(CMD_UserCert_O)                    ///获取下一个
            % QString("#") % GlobalVars::g_localUser.getNumber() % "|1";
        emit signalSendMsg(msg);
        emit signalSetUserCertList(true,"");
    }else
    {
        if (list.at(1) == "没有下一条记录")
        {
            QString msg = QString(CMD_UserCertImage_K)                  /// 获取图片
                % QString("#") % GlobalVars::g_localUser.getNumber() % "|0";
            emit signalSendMsg(msg);
        }
        else /// 没有可认证的
        {
            emit signalSetUserCertList(false,list.at(1));
        }
    }
}

void MsgSocket::parseUserCertResult(const QString& data)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();

    ///!/? | msgRemind
    if (RES_Down == res)
    {
        emit signalUserCertResult(true,list.at(1));
    }else
    {
        emit signalUserCertResult(false,list.at(1));
    }
}

void MsgSocket::parseUserCertImage(QString data, const QImage &image)
{
    QStringList list = data.split("|");
    int res = data.at(0).toLatin1();

    if (RES_Down == res)
    {
        QString userID = list.at(1);
        QString msg = QString(CMD_UserCertImage_K)                ///获取同一个认证的下一个图片
                    % QString("#") % GlobalVars::g_localUser.getNumber() % "|1";
        emit signalSendMsg(msg);
        emit signalSetUserCertImage(true,userID, image);
    }
    else
    {
        QString message = list.at(1);
        if (message == "没有下一条记录")
        {
            QString msg = QString(CMD_UserCertImage_K)                ///获取酒店下一个认证的图片
                        % QString("#") % GlobalVars::g_localUser.getNumber() % "|2";
            emit signalSendMsg(msg);
        }
        else                                                                                /// 没有下一个认证存在
        {
            emit signalSetUserCertImage(false,message,image);
        }
    }
}


